home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / amos / AMOS1097.lzh / AMOSLIST / 000048_amos-request@svcs1.digex.net_Fri Oct 3 08:39:28 1997.msg < prev    next >
Internet Message Format  |  1997-11-02  |  2KB

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
  2.     by mail2.access.digex.net (8.8.5/8.8.5) with ESMTP id IAA22552
  3.     for <mcox@access.digex.net>; Fri, 3 Oct 1997 08:39:26 -0400 (EDT)
  4. Received: (from daemon@localhost)
  5.     by svcs1.digex.net (8.8.5/8.8.5) id HAA01378
  6.     for amos-out; Fri, 3 Oct 1997 07:20:08 -0400 (EDT)
  7. Received: from mail2.access.digex.net (mail2.access.digex.net [205.197.247.3])
  8.     by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id HAA01375
  9.     for <amos-list@svcs1.digex.net>; Fri, 3 Oct 1997 07:20:07 -0400 (EDT)
  10. Received: from MCSDEV.MCS.CO.UK (SYSTEM@mcsdev.mcs.co.uk [193.32.50.112])
  11.     by mail2.access.digex.net (8.8.5/8.8.5) with SMTP id HAA14165
  12.     for <amos-list@access.digex.net>; Fri, 3 Oct 1997 07:20:05 -0400 (EDT)
  13. Date:     Fri, 3 Oct 1997 09:57 GMT
  14. From: "SIMONC%MARS.decnet"@mcs.co.uk (Simon Champion - simonc@mcs.co.uk)
  15. Message-Id: <009BB36B2C28DDE0.153D@mcs.co.uk>
  16. To: amos-list@access.digex.net
  17. Subject:  Re: Sorting routine
  18. X-VMS-To: MCSDEV::SMTP%"amos-list@access.digex.net"
  19. Status: O
  20. X-Status: 
  21.  
  22. Subj:    Re: Sorting routine.
  23.  
  24.  
  25. >Hi!
  26.  
  27. >Is there a smooth way to sort 20 variables???
  28. >and not do like this..
  29.  
  30. >--------------------------------
  31. >If score1_1(1)>score2_1(1)
  32. >   Loke S7+40,Leek(S5+20)
  33. >endif
  34. >if score1_2(2)>score2_1(1)
  35. >   loke s7+60,leek(s5+40)
  36. >endif
  37. >-------------------------------
  38.  
  39. >This way makes the program very big..!
  40. >Any soloution anyone????
  41.  
  42.  
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44.  
  45. There's loads of different methods of sorting an array.
  46. Most of them use loops. The quickest ones use recursion.
  47.  
  48. I'm sure there's a "Sort" command in Amos. I recall ever having
  49. used it, but I'm sure it's there.
  50.  
  51. If you can't use that, try this:
  52.  
  53. cnt   - loop counter
  54. cnt2  - second loop counter
  55. siz   - number of array elements
  56. srt() - the array to sort
  57. tmp   - a temporary var to hold a copy of one srt().
  58.  
  59. For cnt=1 to siz-1
  60.    For cnt2=cnt+1 to siz
  61.       Rem Out of sequence?
  62.       If srt(cnt) > srt(cnt2)
  63.      Rem then swap the two variables.
  64.          tmp=srt(cnt)
  65.      srt(cnt)=srt(cnt2)
  66.      srt(cnt2)=tmp
  67.       Endif
  68.    Next
  69. Next
  70.  
  71.  
  72. A recursive 'quick sort' would be much quicker, but isn't easy to
  73. understand like this one.
  74.  
  75. Hope that answers your question.
  76.  
  77. See ya.
  78.  
  79.  
  80.  
  81.  
  82.          SimonC.